package java_thinking.unit_18_IO._18_1;

import java.io.File;

/**
 * @Desc:   使用Directory.walk()来计算在目录中所有名字与特定的正则表达式相匹配的文件的尺寸总和；
 * @author: cww
 * @DateTime: 2019-05-12 20:59
 */

public class E04_DirSize2 {
    public static void main(String[] args) {
        Directory.TreeInfo ti;
        ti = Directory.walk("./cache",".*\\.txt");
        long total = 0;
        for (File file : ti) {
            total += file.length();
        }
        System.out.println(ti.files.size() + " file(s), " + total + " bytes");
    }
}
